home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / accessibility / UIComponentAccImpl.as < prev   
Text File  |  2014-03-27  |  7KB  |  214 lines

  1. package mx.accessibility
  2. {
  3.    import flash.accessibility.Accessibility;
  4.    import flash.accessibility.AccessibilityProperties;
  5.    import flash.display.DisplayObjectContainer;
  6.    import flash.events.Event;
  7.    import mx.containers.Form;
  8.    import mx.containers.FormHeading;
  9.    import mx.containers.FormItem;
  10.    import mx.controls.FormItemLabel;
  11.    import mx.controls.Label;
  12.    import mx.controls.scrollClasses.ScrollBar;
  13.    import mx.core.Application;
  14.    import mx.core.Container;
  15.    import mx.core.UIComponent;
  16.    import mx.core.mx_internal;
  17.    
  18.    use namespace mx_internal;
  19.    
  20.    public class UIComponentAccImpl extends AccessibilityProperties
  21.    {
  22.       
  23.       private static var accessibilityHooked:Boolean = hookAccessibility();
  24.       
  25.       mx_internal static const VERSION:String = "3.0.0.0";
  26.        
  27.       
  28.       protected var master:UIComponent;
  29.       
  30.       private var oldErrorString:String;
  31.       
  32.       private var oldToolTip:String;
  33.       
  34.       public function UIComponentAccImpl(param1:UIComponent)
  35.       {
  36.          var _loc2_:String = null;
  37.          super();
  38.          master = param1;
  39.          if(param1.accessibilityProperties)
  40.          {
  41.             silent = param1.accessibilityProperties.silent;
  42.             forceSimple = param1.accessibilityProperties.forceSimple;
  43.             noAutoLabeling = param1.accessibilityProperties.noAutoLabeling;
  44.             if(param1.accessibilityProperties.name)
  45.             {
  46.                name = param1.accessibilityProperties.name;
  47.             }
  48.             if(param1.accessibilityProperties.description)
  49.             {
  50.                description = param1.accessibilityProperties.description;
  51.             }
  52.             if(param1.accessibilityProperties.shortcut)
  53.             {
  54.                shortcut = param1.accessibilityProperties.shortcut;
  55.             }
  56.          }
  57.          if(master is ScrollBar)
  58.          {
  59.             silent = true;
  60.          }
  61.          else if(master is FormItemLabel)
  62.          {
  63.             name = getFormName(master);
  64.             silent = true;
  65.          }
  66.          else
  67.          {
  68.             _loc2_ = getFormName(master);
  69.             if(_loc2_ && _loc2_.length != 0)
  70.             {
  71.                name = _loc2_ + name;
  72.             }
  73.             if(master.toolTip && master.toolTip.length != 0)
  74.             {
  75.                oldToolTip = " " + master.toolTip;
  76.                name += oldToolTip;
  77.             }
  78.             if(master.errorString && master.errorString.length != 0)
  79.             {
  80.                oldErrorString = " " + master.errorString;
  81.                name += oldErrorString;
  82.             }
  83.             master.addEventListener("toolTipChanged",eventHandler);
  84.             master.addEventListener("errorStringChanged",eventHandler);
  85.          }
  86.       }
  87.       
  88.       private static function updateFormItemString(param1:FormItem) : String
  89.       {
  90.          var _loc3_:Label = null;
  91.          var _loc6_:int = 0;
  92.          var _loc7_:int = 0;
  93.          var _loc8_:UIComponent = null;
  94.          var _loc2_:* = "";
  95.          _loc3_ = param1.itemLabel;
  96.          var _loc4_:AccessibilityProperties;
  97.          if((_loc4_ = !!_loc3_ ? _loc3_.accessibilityProperties : null) && _loc4_.silent)
  98.          {
  99.             return _loc4_.name;
  100.          }
  101.          var _loc5_:UIComponent;
  102.          if((_loc5_ = UIComponent(param1.parent)) is Form)
  103.          {
  104.             _loc7_ = _loc6_ = _loc5_.getChildIndex(param1);
  105.             while(_loc7_ >= 0)
  106.             {
  107.                if((_loc8_ = UIComponent(_loc5_.getChildAt(_loc7_))) is FormHeading)
  108.                {
  109.                   _loc2_ = FormHeading(_loc8_).label + " ";
  110.                   break;
  111.                }
  112.                _loc7_--;
  113.             }
  114.          }
  115.          if(param1.required)
  116.          {
  117.             _loc2_ += "Required Field ";
  118.          }
  119.          if(param1.label != "")
  120.          {
  121.             _loc2_ += param1.label + " ";
  122.          }
  123.          if(_loc4_ && !_loc4_.silent)
  124.          {
  125.             _loc4_.silent = true;
  126.             _loc4_.name = _loc2_;
  127.          }
  128.          return _loc2_;
  129.       }
  130.       
  131.       mx_internal static function createAccessibilityImplementation(param1:UIComponent) : void
  132.       {
  133.          param1.accessibilityProperties = new UIComponentAccImpl(param1);
  134.       }
  135.       
  136.       public static function getFormName(param1:UIComponent) : String
  137.       {
  138.          var _loc2_:String = "";
  139.          if(param1 is Container)
  140.          {
  141.             return _loc2_;
  142.          }
  143.          var _loc3_:DisplayObjectContainer = param1.parent;
  144.          while(_loc3_ && !(_loc3_ is FormItem) && !(_loc3_ is Application) && _loc3_ != param1.root)
  145.          {
  146.             _loc3_ = _loc3_.parent;
  147.          }
  148.          if(_loc3_ && _loc3_ is FormItem)
  149.          {
  150.             _loc2_ = updateFormItemString(FormItem(_loc3_));
  151.          }
  152.          return _loc2_;
  153.       }
  154.       
  155.       public static function enableAccessibility() : void
  156.       {
  157.       }
  158.       
  159.       private static function hookAccessibility() : Boolean
  160.       {
  161.          UIComponent.createAccessibilityImplementation = mx_internal::createAccessibilityImplementation;
  162.          return true;
  163.       }
  164.       
  165.       protected function eventHandler(param1:Event) : void
  166.       {
  167.          var _loc2_:int = 0;
  168.          switch(param1.type)
  169.          {
  170.             case "errorStringChanged":
  171.                if(name && name.length != 0 && oldErrorString)
  172.                {
  173.                   _loc2_ = name.indexOf(oldErrorString);
  174.                   if(_loc2_ != -1)
  175.                   {
  176.                      name = name.substring(0,_loc2_) + name.substring(_loc2_ + oldErrorString.length);
  177.                   }
  178.                   oldErrorString = null;
  179.                }
  180.                if(master.errorString && master.errorString.length != 0)
  181.                {
  182.                   if(!name)
  183.                   {
  184.                      name = "";
  185.                   }
  186.                   oldErrorString = " " + master.errorString;
  187.                   name += oldErrorString;
  188.                }
  189.                Accessibility.updateProperties();
  190.             case "toolTipChanged":
  191.                if(name && name.length != 0 && oldToolTip)
  192.                {
  193.                   _loc2_ = name.indexOf(oldToolTip);
  194.                   if(_loc2_ != -1)
  195.                   {
  196.                      name = name.substring(0,_loc2_) + name.substring(_loc2_ + oldToolTip.length);
  197.                   }
  198.                   oldToolTip = null;
  199.                }
  200.                if(master.toolTip && master.toolTip.length != 0)
  201.                {
  202.                   if(!name)
  203.                   {
  204.                      name = "";
  205.                   }
  206.                   oldToolTip = " " + master.toolTip;
  207.                   name += oldToolTip;
  208.                }
  209.                Accessibility.updateProperties();
  210.          }
  211.       }
  212.    }
  213. }
  214.